package tgc.edu.ljc.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import tgc.edu.ljc.entity.Student;

public class SessionInterceptor extends HandlerInterceptorAdapter{

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		Student student= (Student) request.getSession().getAttribute("user");
		if(student==null) {
			response.sendRedirect(request.getContextPath()+"/student/login");
			return false;
		}
		return super.preHandle(request, response, handler);
	}

}
